package com.javabase.y2021.m12.day1215;

import java.nio.CharBuffer;

/**
 * @descriptions: BufferTest
 * @author: Tom
 * @date: 2021/12/15 上午 10:52
 * @version: 1.0
 */
public class Code01_BufferTest {
    public static void main(String[] args) {
        CharBuffer buff = CharBuffer.allocate(8);
        System.out.println("capacity:" + buff.capacity());
        System.out.println("limit:" + buff.limit());
        System.out.println("position:" + buff.position());
        System.out.println("size:" + buff.length());
        System.out.println("get position 0:" + buff.get(0));
        buff.put('a');
        buff.put('b');
        buff.put('c');
        System.out.println("執行put方法之後:");
        System.out.println("capacity:" + buff.capacity());
        System.out.println("limit:" + buff.limit());
        System.out.println("position:" + buff.position());
        System.out.println("size:" + buff.length());
        buff.flip();
        System.out.println("執行flip方法之後:");
        System.out.println("capacity:" + buff.capacity());
        System.out.println("limit:" + buff.limit());
        System.out.println("position:" + buff.position());
        System.out.println("size:" + buff.length());
        buff.clear();
        System.out.println("執行clear方法之後:");
        System.out.println("capacity:" + buff.capacity());
        System.out.println("limit:" + buff.limit());
        System.out.println("position:" + buff.position());
        System.out.println("size:" + buff.length());


    }
}















